<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./OL_SDK/include-openlayers-local.js"></script>
    <script src="./libs/gaode.js"></script>
</head>

<body>
    <button onclick="getFeatures()">获取要素</button>
    <div id="map">
    </div>
    <script>
        var map = new ol.Map({
            target: "map",
            layers: [gaode],
            view: new ol.View({
                projection: 'EPSG:4326',
                center: [114.30, 30.50],
                zoom: 4
            })
        })
        //    1、画布  --本质上就是空source的layer
        // 2、创建画笔
        // 3、将画笔添加地图
        /* 1、layer --画布*/
        let source = new ol.source.Vector({})
        let layer = new ol.layer.Vector({
            source
        })
        map.addLayer(layer)
        /* 2、创建画笔  */
        let draw = new ol.interaction.Draw({
            type: "Point",
            source
        })
        /* 3、将画笔添加到地图 */
        // console.log(map,'map')
        map.addInteraction(draw);
        let style = new ol.style.Style({
            image: new ol.style.Circle({
                radius: 18,
                fill: new ol.style.Fill({
                    color: "#333"
                })
            })
        })
        var high_source = new ol.source.Vector({})
        var high_layer = new ol.layer.Vector({
            source: high_source,
            style
        })
        map.addLayer(high_layer)
        const zIndex = high_layer.getZIndex()
        // console.log(high_layer,'high_layer')
        // console.log(zIndex, 'zIndex')
        layer.setZIndex(1)
        function getFeatures() {
            /* 设置要素样式  radius:18  color:"#333" */
            var features = source.getFeatures()
            high_source.addFeatures(features)
            source.clear()
        }
    </script>
</body>

</html>